package org.example.strategy;

import org.example.strategy.improve.FlyBehavior;

/**
 * @author wangbin
 * @date 2024/4/20
 * @vesion 1.0
 */
public abstract class Duck {

    FlyBehavior flyBehavior;

    public abstract void display();

    public void quack(){
        System.out.println("鸭子嘎嘎嘎");
    }

    public void swim(){
        System.out.println("鸭子游泳游泳");

    }

    public void fly(){
        if(flyBehavior != null){
            flyBehavior.fly();
        }
    }


    public FlyBehavior getFlyBehavior() {
        return flyBehavior;
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }
}
